package com.op.model.vo;

import com.op.entity.MenuJoinRoleMenu;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * ClassName： ComponentRouterVo
 * Date： 2021/12/30 22:01
 *
 * @author 孤焰
 * @version 1.0
 **/

@ApiModel("组件路由")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ComponentRouterVo implements Serializable {
    private static final long serialVersionUID = 7938380228535764281L;

    @ApiModelProperty("路由路径")
    private String path;

    @ApiModelProperty("组件名")
    private String name;

    @ApiModelProperty("组件路径")
    private String component;

    @ApiModelProperty("此路由下被授权的角色")
    private List<Long> roleIds;

    public ComponentRouterVo(MenuJoinRoleMenu menu) {
        this.path = menu.getPath();
        this.name = menu.getName();
        this.component = menu.getComponent();
        this.roleIds = new ArrayList<>();
        this.roleIds.add(menu.getRoleId());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ComponentRouterVo that = (ComponentRouterVo) o;
        return Objects.equals(path, that.path) && Objects.equals(component, that.component);
    }

    @Override
    public int hashCode() {
        return Objects.hash(path, component);
    }
}
